<!--菜单添加-->
<div class="dialog_content" style="max-height: 450px; overflow-y: auto;">
    <form id="info_form" name="info_form" action="{:U('Communicate/add')}" method="post">
        <table width="100%" class="table_form">
            <tr>
                <td colspan="6" style="color: #666666;padding: 5px 10px">
                    <b>客户姓名 : </b>
                    <input type="text" style="width: 100px;" name="name" class="input-text" value="{$info.name}">
                    <b style="padding-left: 10px">需求金额(元) : </b>
                    <input type="text" style="width: 100px" name="money" class="input-text" value="{$info.money}">
                    <b style="padding-left: 10px">性别 : </b>
                    <select name="sex" id="communicate_sex">
                        <option value="">请选择</option>
                        <option value="男">男</option>
                        <option value="女">女</option>
                    </select>
                    <b style="padding-left: 10px">手机号 : </b>
                    <if condition="$info['id']">
                        {$info.mobile}
                        <!--<a href="javascript:;" id="dustess" rel="{$info.id}" style="display: inline-block;padding: 0px 8px;line-height: 23px;font-size: 12px;text-decoration:none;background: #33bbee;border-radius: 5px;color: #FFF;">-->
                            <!--一键外呼-->
                        <!--</a>-->
                        <else/>
                        <input style="width: 100px" type="text" name="mobile" class="input-text" value="{$info.mobile}">
                    </if>
                    <b style="padding-left: 10px">所在城市 : </b>
                    <if condition="$info['id']">
                        {$info.city}
                        <else/>
                        <select name="city" id="add_city">
                            <option value=""></option>
                            <foreach name="allocateCity" item="vo">
                                <option value="{$vo}">{$vo}</option>
                            </foreach>
                        </select>
                    </if>
                </td>
            </tr>

            <tr>
                <td colspan="6" style="color: #666666;padding: 5px 10px">
                    <b>是否接通 : </b>
                    <select name="is_jietong" id="communicate_is_jietong">
                        <option value="">请选择</option>
                        <option value="1">接通</option>
                        <option value="0">未接通</option>
                    </select>
                    <b style="padding-left: 20px">是否意向 : </b>
                    <select name="is_yixiang" id="communicate_is_yixiang">
                        <option value="">请选择</option>
                        <option value="1">有意向</option>
                        <option value="0">无意向</option>
                    </select>
                    <b style="padding-left: 15px">跟进状态 : </b>
                    <select name="follow_type" id="communicate_follow_type">
                        <option value="">请选择</option>
                        <foreach name="customer_follow_type" item="vo">
                            <option value="{$vo}">{$vo}</option>
                        </foreach>
                    </select>
                    <b style="padding-left: 20px">客户星级 : </b>
                    <select name="level" id="add_level">
                        <option value="">请选择</option>
                        <if condition="$customer_top_star egt 1">
                            <option value="A">1星</option>
                        </if>
                        <if condition="$customer_top_star egt 2">
                            <option value="B">2星</option>
                        </if>
                        <if condition="$customer_top_star egt 3">
                            <option value="C">3星</option>
                        </if>
                        <if condition="$customer_top_star egt 4">
                            <option value="D">4星</option>
                        </if>
                        <if condition="$customer_top_star egt 5">
                            <option value="E">5星</option>
                        </if>
                        <if condition="$customer_top_star egt 6">
                            <option value="F">6星</option>
                        </if>
                        <if condition="$customer_top_star egt 7">
                            <option value="G">7星</option>
                        </if>
                        <if condition="$customer_top_star egt 8">
                            <option value="H">>8星</option>
                        </if>
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="6" style="color: #666666;padding: 5px 10px">
                    <b style="padding-left: 22px">房 : </b>
                    <select name="has_house" id="communicate_has_house">
                        <option value="">请选择</option>
                        <option value="有">有</option>
                        <option value="无">无</option>
                    </select>
                    <b>车 : </b>
                    <select name="has_car" id="communicate_has_car">
                        <option value="">请选择</option>
                        <option value="无">无</option>
                        <option value="有">有</option>
                    </select>
                    <b>保单 : </b>
                    <select name="has_baodan" id="communicate_has_baodan">
                        <option value="">请选择</option>
                        <option value="无">无</option>
                        <option value="有">有</option>
                    </select>
                    <b>公积金 : </b>
                    <select name="has_gongjijin" id="communicate_has_gongjijin">
                        <option value="">请选择</option>
                        <option value="无">无</option>
                        <option value="有">有</option>
                    </select>
                    <b>社保 : </b>
                    <select name="has_shebao" id="communicate_has_weilidai">
                        <option value="">请选择</option>
                        <option value="无">无</option>
                        <option value="有">有</option>
                    </select>
                    <b>营业执照 : </b>
                    <select name="has_yingyezhizhao" id="communicate_has_nasui">
                        <option value="">请选择</option>
                        <option value="无">无</option>
                        <option value="有">有</option>
                    </select>
                </td>
            </tr>

            <if condition="$info['id']">
                <tr>
                    <th style="border-right:1px solid #ebeef5;">沟通内容 :</th>
                    <td colspan="5" style="padding: 5px">
                        <textarea name="content" style="width: 630px"></textarea>
                    </td>
                </tr>
                <tr>
                    <th style="border-right:1px solid #ebeef5;">沟通记录 :</th>
                    <td colspan="5" class="communicate_list" style="padding: 5px"></td>
                </tr>
                <tr>
                    <th style="border-right:1px solid #ebeef5;">备注描述 :</th>
                    <td colspan="5" style="padding: 5px">
                        <!--<div style="color: #fc4f02;">为了非常直观的了解客户，请仔细对客户进行描述。</div>-->
                        <textarea name="remark" style="width: 630px;">{$info.remark}</textarea>
                    </td>
                </tr>
                <tr>
                    <th style="border-right:1px solid #ebeef5;">闹铃提醒 :</th>
                    <td colspan="5" style="padding: 5px">
                        提醒时间：<input type="text" name="last_lianxi_time" id="last_lianxi_time" class="date" size="15" style="padding-left: 5px;"><br>
                        提醒内容：<input type="text" name="last_lianxi_content" id="last_lianxi_content" class="input-text" style="width: 570px;"><br>
                        <input id="add_last_lianxi" type="button" style="width: auto;padding-left: 10px;padding-right: 10px;margin-left: 60px;" class="smt" value="新增闹铃备忘" data-title="新增闹铃备忘">
                    </td>
                </tr>
                <tr>
                    <th style="border-right:1px solid #ebeef5;">闹铃提醒记录 :</th>
                    <td colspan="5" class="beiwangjilu_list" style="padding: 5px"></td>
                </tr>
            </if>

            <tr>
                <th style="border-right:1px solid #ebeef5;">客户地址 :</th>
                <td colspan="5" style="padding: 5px"><input type="text" name="address" id="address" class="input-text" value="{$info.address}" style="width: 630px;"></td>
            </tr>
            <tr>
                <th style="border-right:1px solid #ebeef5;">房产地址 :</th>
                <td colspan="5" style="padding: 5px"><input type="text" name="house_address" id="house_address" class="input-text" value="{$info.house_address}" style="width: 630px;"></td>
            </tr>
            <tr>
                <th colspan="6" style="text-align: left;background: #cecece;">其他信息 :</th>
            </tr>
            <foreach name="info.ext" item="vo">
                <tr>
                    <th style="border-right:1px solid #ebeef5;">{$vo.filed_name} :</th>
                    <td colspan="5" style="padding: 5px"><input type="text" name="{$vo.filed}" class="input-text" value="{$vo.value}" style="width: 630px;"></td>
                </tr>
            </foreach>
        </table>
        <input type="hidden" name="id" class="input-text" value="{$info.id}">
    </form>
</div>

<script>
    //新增闹铃备忘
    $('#add_last_lianxi').click(function(){
        var order_id = "{$info.id}";
        var last_lianxi_time = $('#last_lianxi_time').val();
        var last_lianxi_content = $('#last_lianxi_content').val();
        $.ajax({
            type: "POST",
            url: "{:U('Admin/Communicate/addLastLianxi')}",
            data: {id:order_id,last_lianxi_time:last_lianxi_time,last_lianxi_content:last_lianxi_content},
            dataType: "json",
            success: function (result) {
                if(result.errNum === 0){
                    var link_lianxi = "{:U('Communicate/contact_list')}?order_id={$info.id}";
                    loadURL(link_lianxi,'.beiwangjilu_list');
                    $('#last_lianxi_time').val("")
                    $('#last_lianxi_content').val("");
                    $.yhxia.tip({content:result.retData});
                } else {
                    $.yhxia.tip({content:result.errMsg, icon:'alert'});
                }
            }
        });
    });
</script>

<script>
    $(function(){
        $.formValidator.initConfig({formid:"info_form",autotip:true});
        $('#info_form').ajaxForm({success:complate,dataType:'json'});
        function complate(result){
            if(result.errNum === 0){
                $.dialog.get('add-communicate').close();
                $.yhxia.tip({content:result.retData});
                window.location.reload();
            } else {
                $.yhxia.tip({content:result.errMsg, icon:'alert'});
            }
        }
    });
    //一键外呼
    $('#dustess').click(function(){
        let customer_id = $(this).attr('rel');
        $.ajax({
            type: "GET",
            url: "{:U('Admin/Dustess/callPhone')}",
            data: {id: customer_id},
            dataType: "json",
            success: function (result) {
                if(result.errNum === 0){
                    $.yhxia.tip({content:'呼叫中...',time: 3000});
                } else {
                    $.yhxia.tip({content:result.errMsg, icon:'alert',time: 2000});
                }
            }
        });
    });
</script>
<if condition="$info['id']">
    <script>
        Calendar.setup({
            inputField : "last_lianxi_time",
            ifFormat   : "%Y-%m-%d %H:%M:00",
            showsTime  : true,
            timeFormat : "24"
        });
        var link = "{:U('Communicate/list1')}?order_id={$info.id}";
        loadURL(link,'.communicate_list');
        var link_lianxi = "{:U('Communicate/contact_list')}?order_id={$info.id}";
        loadURL(link_lianxi,'.beiwangjilu_list');
    </script>
    <script type="text/javascript">
        $('#communicate_sex').val("{$info['sex']}");
        $('#add_city').val("{$info['city']}");
        $('#communicate_follow_type').val("{$info['follow_type']}");
        $('#add_level').val("{$info['level']}");
        $('#communicate_has_house').val("{$info['has_house']}");
        $('#communicate_has_car').val("{$info['has_car']}");
        $('#communicate_has_baodan').val("{$info['has_baodan']}");
        $('#communicate_has_gongjijin').val("{$info['has_gongjijin']}");
        $('#communicate_has_weilidai').val("{$info['has_weilidai']}");
        $('#communicate_has_nasui').val("{$info['has_nasui']}");
        $('#communicate_is_jietong').val("{$info['is_jietong']}");
        $('#communicate_is_yixiang').val("{$info['is_yixiang']}");
    </script>
</if>
